# Maintainer: Justin Kromlinger <hashworks@archlinux.org>

pkgname=python-geoipsets
pkgver=2.3.5
pkgrel=2
pkgdesc='Tool to generate country-specific IP ranges for iptables/ipset and nftables'
arch=('any')
license=('GPL3')
url='https://github.com/chr0mag/geoipsets/tree/main/python'
depends=(
  'python-requests'
  'python-beautifulsoup4'
)
makedepends=(
  'python-setuptools'
)
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/chr0mag/geoipsets/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('9a39769311b8b48a56f35e4697f5f9f872486271db748a1c580856bae323c3f19d6595095bf9d7c49f78450a95547fa69a76a013691dd4547927d13d5b2d6b21')

build() {
  cd "geoipsets-$pkgver/python"

  python setup.py build
}

check() {
  cd "geoipsets-$pkgver/python"

  python -m pytest
}

package() {
  cd "geoipsets-$pkgver/python"

  python setup.py install --root="$pkgdir" --optimize=1

  install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README_python.md"
  install -Dm644 ../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm644 ../README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
  install -Dm644 ../systemd/update-geoipsets.service "${pkgdir}/usr/lib/systemd/system/update-geoipsets.service"
  install -Dm644 ../systemd/update-geoipsets.timer "${pkgdir}/usr/lib/systemd/system/update-geoipsets.timer"
}
